package chap6;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class SortArray {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[6];
        System.out.print("输入6个数:");
        for(int i=0;i<a.length;i++){
            a[i]=sc.nextInt();
        }
        System.out.println("初始的顺序：");
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
        Arrays.sort(a);//只能按照从小到大
        System.out.println("排序后：");
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
        System.out.println("从大到小输出：");
        for(int i=a.length-1;i>=0;i--){
            System.out.print("\t"+a[i]);
        }
//        System.out.println(a[a.length-1]);
//        System.out.println(a[a.length-2]);
//        System.out.println(a[a.length-3]);
//        System.out.println(a[a.length-4]);

    }
}
